
package io.dbw.common.utils;

import io.dbw.common.exception.BusinessException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.Collection;

/**
 * 数据校验
 *
 * 
 */
public abstract class AssertUtils {

    public static void isBlank(String str, String message) {
        if (StringUtils.isBlank(str)) {
            throw new BusinessException(message);
        }
    }

    public static void isNull(Object object, String message) {
        if (object == null || StringUtils.isBlank(object.toString())) {
            throw new BusinessException(message);
        }
    }

    public static void isEmpty(Collection<? extends Serializable> collection, String message) {
        if (CollectionUtils.isEmpty(collection)) {
            throw new BusinessException(message);
        }
    }
}
